import { WebSocketServer } from "ws";
import fs from "fs";
import https from "https";
const wss = new WebSocketServer({
  port: 8000,
  server: https.createServer({
    key: fs.readFileSync("xiaoyueyue.com.cn.key"), // 私钥路径
    cert: fs.readFileSync("xiaoyueyue.com.cn.crt"), // 证书路径
  }),
});

wss.on("connection", (ws) => {
  console.log("连接成功了...");
  ws.send("您连接成功啦");
  ws.on("message", (data) => {
    console.log("接收到用户消息", data);
    ws.send("Hello, Client!");
  });
});
console.log("创建服务成功:8000");
